
import 'package:flutter/widgets.dart';
import 'package:flutter_app/http/DioRepository.dart';
import 'package:flutter_app/model/FictionChapterData.dart';
import 'package:fluttertoast/fluttertoast.dart';

class FictionPageViewModel extends ChangeNotifier{

  List<FictionChapterData> list = [];

  ///<p>获取章节</p>
  ///[fictionId] 小说id
  getChapter(String fictionId){
    DioRepository().getFictionChapters(fictionId, onSuccess: (rep){
      var value = BaseFictionChapterData.fromJson(rep);
      if(value.code == 0) {
        list.addAll(value.data.data);
        notifyListeners();
      }else{
        Fluttertoast.showToast(msg: value.msg);
      }
    });
  }

}